﻿using BussinessObject.ObjectTwo;
using Class_Entity.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectHK3.App_Code;
namespace ProjectHK3.Object_One
{
    public partial class CompanyDetails : System.Web.UI.Page
    {
        B_Update gx = new B_Update();
        B_Search ex = new B_Search();
        Companies fx = new Companies();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                load();
            }
        }
        public void load()
        {
            fx = ex.loadCom(int.Parse(Session["companyId"].ToString()));
            TextBox1.Text = fx.COMPANY_CODE;
            TextBox2.Text = fx.COMPANY_NAME;
            TextBox3.Text = fx.COMPANY_ADDRESS;
            TextBox4.Text = fx.COMPANY_PHONE;
            TextBox5.Text = fx.COMPANY_EMAIL;
            TextBox6.Text = fx.DESCRIPTION;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            fx.COMPANY_ID = int.Parse(Session["companyId"].ToString());
            fx.COMPANY_NAME = TextBox2.Text.ToString();
            fx.COMPANY_PHONE = TextBox4.Text.ToString() ;
            fx.COMPANY_EMAIL = TextBox5.Text.ToString();
            fx.COMPANY_CODE = TextBox1.Text.ToString();
            fx.COMPANY_ADDRESS = TextBox3.Text.ToString();
            fx.DESCRIPTION = TextBox6.Text.ToString();
            if (gx.updateCom(fx) == true)
            {
                Alert.Show("OK");
                load();
            }
            else
            {
                Alert.Show("false");
                load();
            }
            //Response.Redirect("../Object One/Company.aspx");
        }

        protected void Button3_Click(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("../Object One/Company.aspx");
        }
    }
}